package com.motorwaymanage.impl;

import java.io.IOException;

import org.apache.ibatis.session.SqlSession;

import com.motorwaymanage.beans.Admin;
import com.motorwaymanage.biz.IAdminBiz;
import com.motorwaymanage.dao.DBAccess;

public class AdminBizImpl implements IAdminBiz{
	private DBAccess db=new DBAccess();
	@Override
	public Admin checkAdmin(Admin admin) {
		SqlSession session = null;
		Admin admin1=null;
		try {
			session=db.getSqlSession();
			IAdminBiz adminBiz=session.getMapper(IAdminBiz.class);
			admin1=adminBiz.checkAdmin(admin);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return admin1;
	}
	
	@Override
	public int updateAdminPwd(Admin admin) {
		SqlSession session = null;
		int result=0;
		try {
			session=db.getSqlSession();
			IAdminBiz adminBiz=session.getMapper(IAdminBiz.class);
			result=adminBiz.updateAdminPwd(admin);
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}
}
